import axios from '@/utils/request'
import { SkuResponseData, getSkuResponseInfo } from './type'
import { AddSku } from '../spu/type'

enum API {
  FINDSKULIMIT_URL = '/admin/product/list/',
  ONORDOWN_URL = '/admin/product/onSale/',
  CANCELSALE_URL = '/admin/product/cancelSale/',
  getskuInfoByskuId = '/admin/product/getSkuInfo/',
  UPDATESKUINFO_URL = '/admin/product/updateSkuInfo',
  DELETESKU_URL = '/admin/product/deleteSku/',
}
//加载sku列表
export const reqGetSkuLimit = (page: number, limit: number) =>
  axios.get<any, SkuResponseData>(API.FINDSKULIMIT_URL + `${page}/${limit}`)
//上架sku
export const reqReOrFa = (skuId: number) =>
  axios.get<any, any>(API.ONORDOWN_URL + skuId)
//下架sku
export const reqCanCel = (skuId: number) =>
  axios.get<any, any>(API.CANCELSALE_URL + skuId)
//获取sku信息
export const reqSkuInfo = (skuId: number) =>
  axios.get<any, getSkuResponseInfo>(API.getskuInfoByskuId + skuId)
//修改sku接口暂未开放
export const upDateGetInfo = (data: AddSku) =>
  axios.post<any, any>(API.UPDATESKUINFO_URL, data)
//删除sku信息
export const reqDeleteSku = (skuId: number) =>
  axios.delete<any, any>(API.DELETESKU_URL + skuId)
